#!/bin/bash

function launch() {
	echo "Launching WeChat Beta..."
	BINROOT=/opt/apps/com.tencent.wechat/files
	bwrap \
		--dev-bind / / \
		--ro-bind ${BINROOT}/license/ /usr/lib/license \
		--ro-bind ${BINROOT}/license/var/ /var/ \
		--ro-bind ${BINROOT}/license/etc/os-release /etc/os-release \
		--ro-bind ${BINROOT}/license/etc/lsb-release /etc/lsb-release \
		--ro-bind-try /usr/lib/snapd-xdg-open/xdg-open /usr/bin/xdg-open \
		--setenv LD_LIBRARY_PATH ${BINROOT} \
		--setenv QT_QPA_PLATFORM xcb \
		--setenv QT_IM_MODULE fcitx \
		--setenv GTK_USE_PORTAL 1 \
		--setenv QT_SCALE_FACTOR 1 \
		${BINROOT}/wechat $@
}

launch $@
